/*
 * TreeLoadDialog.cpp
 *
 *  Created on: 28.04.2010
 *      Author: king
 */

#include "TreeLoadDialog.h"

namespace etu {
namespace ui {

CTreeLoadDialog::CTreeLoadDialog(QWidget* parent, std::list<std::string>* names)
    : QDialog(parent)
{
  setupUi(this);

  connect(m_deleteButton, SIGNAL(pressed()), this, SLOT(deleteTree()));

  for(std::list<std::string>::const_iterator iter = names->begin(); iter != names->end(); ++iter)
	  m_treeNamesCombo->addItem(QString(tr((*iter).c_str())));
}

void CTreeLoadDialog::accept()
{
  if (!m_treeNamesCombo->currentText().isEmpty())
    emit loadTree(QString(m_treeNamesCombo->currentText().toUtf8()).toStdString());

  QDialog::accept();
}

void CTreeLoadDialog::deleteTree()
{
  emit deleteTree(QString(m_treeNamesCombo->currentText().toUtf8()).toStdString());
  m_treeNamesCombo->removeItem(m_treeNamesCombo->currentIndex());
}

}
}
